package game.actor
{
	import away3d.containers.*;
	import engine.asset.*;
	import engine.core.*;
	import engine.graphics.away3d.*;
	import engine.math.*;
	import flash.geom.*;
	import game.*;
	import game.core.*;
	import game.messages.abilities.*;
	import game.messages.gamedata.*;
	import game.messages.simulation.*;
	import game.network.*;
	import game.scene.*;
	import game.store.*;
	import game.ui.core.*;
	
	public class RxHeroLocal extends RxHero
	{
		private var m_timeUntilFullRegen:Number;
		private var m_lastLevelUpMessage:RxSimulation_PlayerLevelUpMessage;
		private var m_xpBoostDuration:Number = 0;
		private var m_energyBoostDuration:Number = 0;
		private var m_lastChainAttackTimeWindow:Number = 0;
		private var m_lastChainAttackIndex:int = 0;
		private var m_lastChainAttackAbility:String = null;
		private var m_energy:Number = 0;
		private var m_energyMax:Number = 0;
		private var m_chargeStop:Boolean = false;
		private var m_boundOffset:int;
		private var m_boundSize:RxVector4;
		private var m_executingAbility:String;
		private var m_executingAbilityId:int;
		private var m_executingAbilityIndex:int;
		private var m_tutorialAbilityCallback:Function;
		private static var s_heroNumber:int = 0;
		private static var s_playerAbilities:RxAbilitiesForPlayer;
		
		public function RxHeroLocal(playerIndex:int)
		{
			var heroName:* = "herolocal" + s_heroNumber;
			m_playerIndex = playerIndex;
			s_heroNumber = s_heroNumber + 1;
			this.m_timeUntilFullRegen = RxServerVars.GetServerVars().secondsUntilPlayerFullRegen;
			super(RxEntityPhase.ENTITY_PHASE_HERO, heroName);
			if (IsViewerLocalHero())
			{
				RxUI.SetAbilityUpdateCallback(this.OnAbilityUpdate);
			}
		}
		
		private function OnAbilityUpdate() : void
		{
			var actionName:String = null;
			var type:int = 0;
			var i:int = 0;
			while (i < BUFF_TYPE_ARRAY_SIZE)
			{
				
				m_buffFloat[i][BUFF_FLOAT_PROPERTY_PASSIVE_BONUS] = 0;
				i++;
			}
			var csv:* = RxAssetCSV.GetByName(RxGameData_NameSpace.ABILITIES);
			var j:int = 0;
			while (j < RxAbilities_StateMessage.NUM_ABILITY_SLOTS)
			{
				
				if (s_playerAbilities.GetActionTypeAtIndex(j) == RxAbilities_ActionBarEntry.TYPE_ABILITY)
				{
					actionName = s_playerAbilities.GetActionNameAtIndex(j);
					if (actionName)
					{
						m_specialAbility[j] = actionName;
						type = GetBuffTypeFromString(csv.GetMappedString("buffType", actionName));
						if (type < BUFF_TYPE_ARRAY_SIZE)
						{
							m_buffFloat[type][BUFF_FLOAT_PROPERTY_PASSIVE_BONUS] = m_buffFloat[type][BUFF_FLOAT_PROPERTY_PASSIVE_BONUS] + csv.GetMappedNumber("buffPerpetual", actionName);
						}
					}
				}
				j++;
			}
		}
		
		public static function FindPlayer() : RxHeroLocal
		{
			return RxHeroLocal(RxHero.FindPlayer());
		}
		
	}
}